/**
 * @author SHIXINGXING
 */

/*添加待办事项*/
function add(){
    window.self.location="item.do?method=addItem";
}
/*删除待办事项*/
function del(){
    var flag = false;
    for (var i = 0; i < document.getElementsByName("ids").length; i++) {
        if (document.getElementsByName("ids")[i].checked) {
            flag = true;
        }
    }
    if (!flag) {
        alert("请选择需要删除的待办事项！");
        return;
    }
    if (window.confirm("确认删除吗？")) {
    
        with (document.getElementById("list")) {
        
            method = "post";
            action = "item.do?method=delItem";
            submit();
        }
    }
}
/*选择待办事项，单选框*/
function selectAll(){
    if (list.checkbox.checked == true) {
        for (var i = 0; i < list.ids.length; i++) 
            list.ids[i].checked = true;
        if (list.ids.length == null) 
            list.ids.checked = true;
    }
    else {
        for (var i = 0; i < list.ids.length; i++) 
            list.ids[i].checked = false;
        if (list.ids.length == null) 
            list.ids.checked = false;
    }
}
/*编辑待办事项*/
function edit(){
    var count = 0;
    var j = 0;
    for (var i = 0; i < document.getElementsByName("ids").length; i++) {
        if (document.getElementsByName("ids")[i].checked) {
            j = i;
            count++;
        }
    }
    if (count == 0) {
        alert("请选择需要修改的待办事项！");
        return;
    }
    if (count > 1) {
        alert("一次只能修改一个待办事项！");
        return;
    }
    if (count == 1) {
        window.self.location = "item.do?method=editItem&itemID=" +
        document.getElementsByName("ids")[j].value;
    }
}